import {Request, Response} from "express";
import {getManager} from "typeorm";
import {User} from "../entity/User";

export async function DeleteByIdAction(request: Request, response: Response) {
    const userRepository = getManager().getRepository(User);
    const id = request.params.id;
    const user = await userRepository.findOneById(id);
    if (user) {
        await userRepository.delete(id);
        response.send('User deleted');
    } else {
        response.send('User not found');
    }
}